using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DTO;
using DAO;
namespace BUS
{
    public enum PhieuThanhLySachBUSResult
    {
        OK,DAOERROR
    }
    public class PhieuThanhLySach
    {
        public static PhieuThanhLySachBUSResult InsertPhieu(DTO.PhieuThanhLySach ph)
        {
            string sql = "insert into PhieuThanhLySach(MaNhanVien,NgayThanhLy) values('";
            sql += ph.MaNhanVien +"','";
            sql += ph.NgayThanhLy;
            sql += "')";
            DAO.Interface dao = new DAO.PhieuThanhLySach();
            bool rs = dao.Insert(sql);
            if (rs)
            {
                sql = "select MaPhieuThanhLy from PhieuThanhLySach";
                DataTable dt = dao.Select(sql);
                if (dt!=null)
                {
                    ph.MaPhieuThanhLySach = int.Parse(dt.Rows[dt.Rows.Count - 1].ItemArray[0].ToString());
                }
                return PhieuThanhLySachBUSResult.OK;
            }
            return PhieuThanhLySachBUSResult.DAOERROR;

        }
    }
}
